//
//  Sqlite.h
//  HomeLInk_HD
//
//  Created by hongbao.cui on 12-5-18.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <sqlite3.h>

#define kDatabaseName @"database.sqlite3"

sqlite3 *database;
//sqlite3 *uerLoginDatabase;

@interface Sqlite : NSObject {

}
//collection
+(BOOL)creatPaperTable;
+(BOOL)addPaper:(NSDictionary *)dict;
+(NSMutableDictionary *)selectResultPaper;
+(NSMutableArray *)selectAllPaper:(NSInteger )index;
+(BOOL)deletePaperIdAt:(NSString*)paper_Id;
+(BOOL)deleteAllPaper;
+(NSString *)finish_flag:(NSString *)paper_id;

//试题历史试卷
+(BOOL)creatQuestionTable;
+(BOOL)insertQuestion:(NSMutableDictionary *)dict;
+(NSMutableArray *)selectCollectionQuestion;//同步练习中的收藏
+(NSMutableArray *)selectCollectionQuestionPaper_Id:(NSString *)paper_id ;
+(NSMutableArray *)selectAllQuestion:(NSString *)paper_id exam_time:(NSString *)exam_time;
+(BOOL)deleteAllQuestion:(NSString *)paperId;
//收藏
+(NSMutableArray *)selectTestCollectionQuestion;//测试中的收藏
+(BOOL)updateCollection:(NSString*)favourite_flag paperId:(NSString *)paperId;
+(BOOL)updateCollection:(NSString*)favourite_flag  orderId:(NSString *)orderid paperId:(NSString *)paperId;
+(int)queryCollectionCount:(NSString*)qtype_name  paper_Id:(NSString *)paper_id;
+(BOOL)deleteQuestionIdAt:(NSString*)question_Id paperId:(NSString *)type qtype:(NSString *)qtype;
+(BOOL)deleteAllCollectionQuestion;
+(BOOL)updateUserAnswer:(NSString*)user_answer paperId:(NSString *)paper_id;
//保存当前进度
+(BOOL)updateCurrentPageFlag:(NSInteger)currentPage paperId:(NSString *)paper_id;

+(NSMutableArray *)selectSimpleQuestion:(NSString *)selectSQL;
//试卷
+(BOOL)creatTestQuestionTable;
+(BOOL)insertTestQuestion:(NSDictionary *)dict;
//简单题中的不定向选择 20160113
+(BOOL)updateSimpleSingleUserAnswer:(NSString*)user_answer user_right_count:(NSString *)user_right_count  tqId:(NSString *)tqId paperId:(NSString *)paperId parentid:(NSString *)parentid;
+(BOOL)updateUserAnswer:(NSString*)user_answer user_right_count:(NSString *)user_right_count  title_id:(NSString *)title_id paperId:(NSString *)paperId;
+(BOOL)updateUserAnswer:(NSString*)updateSQL;
//简单题文字和图片的标示
+(BOOL)updateUserAnswerImage:(NSString*)userAnswerImage paperId:(NSString *)paper_id title_id:(NSString *)title_id;
+(BOOL)updateUserAnswerImage:(NSString*)userAnswerImage paperId:(NSString *)paper_id;
//薄弱知识点
+(NSMutableArray *)selectUserAnswerErrorTestQuestion:(NSString *)paper_id;
+(BOOL)deleteTestQuestionIdAt:(NSString*)paperId;
+(NSMutableDictionary *)selectQuestionRightCount;
+(NSMutableArray *)selectUserAnswerTestQuestion:(NSString *)paper_id;
+(NSMutableArray *)selectTestQuestion:(NSString *)paper_id;
+(BOOL)deleteUserAnswerPaper;
+(NSMutableArray *)selectTestQuestionWhenNOAnswer:(NSString *)paper_id;
+(NSInteger )selectQuestionTypeCount:(NSString *)paperId myqtype:(NSString *)myqtype;


// 新增 --------
+(NSString *)selectUserAnswerWithKey: (NSString*)key paperId:(NSString *)paper_id questionId: (NSString*)qstId;


@end
